﻿package mortal.common.preLoadPage
{
    import Message.Login.*;
    import com.mui.controls.*;
    import extend.language.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;

    public class SelectRoleCellRenderer extends GCellRenderer
    {
        protected var _role:SMyRole;
        protected var _careerSexBmp:GImageBitmap;
        protected var _careerBmp:GImageBitmap;
        protected var _roleBmp:GImageBitmap;
        protected var _nameTxt:GTextFiled;

        public function SelectRoleCellRenderer()
        {
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            super.data = param1;
            this._role = param1 as SMyRole;
            if (!this._careerSexBmp)
            {
                this._careerSexBmp = UIFactory.gImageBitmap("", 0, 0, this);
            }
            if (!this._careerBmp)
            {
                this._careerBmp = UIFactory.gImageBitmap("", 20, 200, this);
            }
            if (!this._roleBmp)
            {
                this._roleBmp = UIFactory.gImageBitmap(ImagesConst.hefuTextMainRole, 53, 10, this);
            }
            if (!this._nameTxt)
            {
                this._nameTxt = UIFactory.gTextField("", 45, 280, 150, 20, this, GlobalStyle.textFormatHuang2.center());
            }
            this._careerSexBmp.imgUrl = "hefuHead_" + this._role.career + "_" + this._role.sex;
            this._careerBmp.imgUrl = "hefuCareer_" + this._role.career;
            this._roleBmp.visible = Boolean(this._role.isMain);
            this._nameTxt.text = PreLanguage.getStringByParam(160, this._role.level.toString(), this._role.name, this._role.oldServerId.toString());
            this.updateFileter();
            return;
        }// end function

        override public function set selected(param1:Boolean) : void
        {
            super.selected = param1;
            this.updateFileter();
            return;
        }// end function

        protected function updateFileter() : void
        {
            if (this._careerSexBmp)
            {
                if (this.selected)
                {
                    this._careerSexBmp.filters = [];
                }
                else
                {
                    this._careerSexBmp.filters = [FilterConst.colorFilter2];
                }
            }
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._role = null;
            this._careerSexBmp.dispose();
            this._careerSexBmp = null;
            this._careerBmp.dispose();
            this._careerBmp = null;
            this._roleBmp.dispose();
            this._roleBmp = null;
            this._nameTxt.dispose();
            this._nameTxt = null;
            return;
        }// end function

    }
}
